/**
 * 
 */
package info.niwota.pasta;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * @author qiangli
 *
 */
public final class Preferences {
	private static final String NOTE_BODY = "note.body";
	private static final String NOTE_TITLE = "note.title";

	private Preferences() {
		//
	}

	public static String getNoteTitle(Context context, String def) {
		try {
			final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
			return pref.getString(NOTE_TITLE, def);
		} catch (Exception e) {
		}
		return def;
	}
	
	public static void putNoteTitle(Context context, String body) {
		final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
		pref.edit().putString(NOTE_TITLE, body).commit();
	}
	
	
	public static String getNoteBody(Context context, String def) {
		try {
			final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
			return pref.getString(NOTE_BODY, def);
		} catch (Exception e) {
		}
		return def;
	}
	
	public static void putNoteBody(Context context, String body) {
		final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
		pref.edit().putString(NOTE_BODY, body).commit();
	}
}
